package com.sloera.holding;

import java.util.ArrayList;

/*
 * @Description Exception in thread "main" java.lang.ClassCastException:
 * @author Nickerg
 * @Date 2020-4-30
 */
public class ApplesAndOrangesWithGenerics {
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        ArrayList<Apple> apples = new ArrayList();
        for (int i = 0; i < 3; i++) {
            apples.add(new Apple());
        }
        //Compile-time error
        //apples.add(new Orange());
        for (Apple apple : apples) {
            System.out.println(apple.id());
        }
    }
}
